#include "task/task_handle_base.h"

using namespace task;

// TODO 上装动作
bool TaskHandleBase::ParseWorkTask(task::sWorkTask &work_task, const std::string &action, const std::string &param)
{
    for (size_t i = 0; i < work_task_types.size(); i++)
    {
        if (action == work_task_types[i])
        {
            //将参数拆分成id, value
            std::vector<std::string> v_param;
            con_lib_.SplitString(param, v_param, ",");
            if (v_param.size() != 2)
            {
                std::cout << "Error: param size should be 2!" << std::endl;
                break;
            }
            work_task.is_receive_cmd = true;
            work_task.type = i;
            work_task.work_id = std::stoi(v_param[0]);
            work_task.value = std::stod(v_param[1]);
            return true;
            break;
        }
    }

    return false;
}
